package com.oauth.components.client.application;

import java.util.ArrayList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratedStackPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.StackLayoutPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.components.client.beans.ApplicationClientBean;

public class RecommendApplications extends Composite {

	private static RecommendApplicationUiBinder uiBinder = GWT
			.create(RecommendApplicationUiBinder.class);

	interface RecommendApplicationUiBinder extends UiBinder<Widget, RecommendApplications> {
	}

	@UiField
	DecoratedStackPanel stackPanel;

	@UiField
	VerticalPanel vPanel;
	
	public RecommendApplications() {
		initWidget(uiBinder.createAndBindUi(this));
		stackPanel.setStackText(0,"<div class=\"stackText\">Recommend App's</div>", true);
		
	}

	public void addApplications(
			ArrayList<ApplicationClientBean> pApplicationList) {
		if (pApplicationList.size() == 0) {
			//vPanel.add(new HTML("<a align=\"right\" href=\"/Browse.html\">Add &raquo;</a>"));
			vPanel.removeFromParent();
		} else {
			for (ApplicationClientBean application : pApplicationList) {
				vPanel.add(new ApplicationItem(application,null));
			}
		}

	}

}
